package cn.xgj.sfzy.controller;

import cn.xgj.sfzy.entity.CourseTalk;
import cn.xgj.sfzy.service.CourseTalkService;
import cn.xgj.sfzy.util.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @ClassName courseTalkController
 * @Description TODO
 * @Author furuyue
 * @Date 2024年10月29日 16:44
 * @Version 1.0
 */

@RestController
@RequestMapping("/courseTalk")
public class courseTalkController {
    @Autowired
    private CourseTalkService courseTalkService;

    @PostMapping("/findById")
    public Result findById(Long id) {
        CourseTalk courseTalk = courseTalkService.findById(id);
        return Result.success(courseTalk);
    }
    //
    @RequestMapping("/findByCourseIdAndPage")
    public Result findByCourseIdAndPage(
            @RequestParam(required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(required = false, defaultValue = "2") Integer pageSize,
            Integer courseId) {
        PageInfo<CourseTalk> byPage = courseTalkService.findByCourseIdAndPage(Long.valueOf(courseId), pageNum, pageSize);
        return Result.success(byPage);
    }

}
